#Prelude
AC_INIT([libssui], [0.5.8], [cgaisford@novell.com])
AC_CONFIG_SRCDIR([src/libssui.h])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

#Checks for programs
AC_PROG_CC
AC_PROG_LIBTOOL
AC_PROG_INTLTOOL([0.29])

#translation support
GETTEXT_PACKAGE=libssui
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
ALL_LINGUAS=""
AM_GLIB_GNU_GETTEXT


# Set pkg-config variables

#GTK20_MINIMUM_VERSION=2.6.0
#AC_SUBST(GTK20_MINIMUM_VERSION)
#AC_SUBST(GTKMOZEMBED_MINIMUM_VERSION)

#Checks for libraries
#PKG_CHECK_MODULES(GTK20, gtk+-2.0 >= $GTK20_MINIMUM_VERSION)
#AC_SUBST(GTK20_CFLAGS)
#AC_SUBST(GTK20_LIBS)

PKG_CHECK_MODULES(GCONF, gconf-2.0)
AC_SUBST(GCONF_CFLAGS)
AC_SUBST(GCONF_LIBS)

PKG_CHECK_MODULES(LIBGNOME, libgnome-2.0)
AC_SUBST(LIBGNOME_CFLAGS)
AC_SUBST(LIBGNOME_LIBS)

PKG_CHECK_MODULES(LIBGNOMEUI, libgnomeui-2.0)
AC_SUBST(LIBGNOMEUI_CFLAGS)
AC_SUBST(LIBGNOMEUI_LIBS)

PKG_CHECK_MODULES(GNOMEVFS, gnome-vfs-2.0)
AC_SUBST(GNOMEVFS_CFLAGS)
AC_SUBST(GNOMEVFS_LIBS)

PKG_CHECK_MODULES(DBUS1, dbus-1)
AC_SUBST(DBUS1_CFLAGS)
AC_SUBST(DBUS1_LIBS)

PKGCONFIG_REQUIRES="gconf-2.0 libgnome-2.0 libgnomeui-2.0 gnome-vfs-2.0 dbus-1"
AC_SUBST(PKGCONFIG_REQUIRES)


# X, Xau, Xmu

AC_CHECK_LIB(Xau, XauFileName,
	     X_LIBS="$X_LIBS -lXau",
	     [AC_MSG_ERROR([Xau development libraries not found])])
AC_CHECK_LIB(Xmu, XmuClientWindow,
	     X_LIBS="$X_LIBS -lXmu",
	     [AC_MSG_ERROR([Xmu development libraries not found])])

# GDM Config File Location

GDMCONFIGFILE=

AC_ARG_WITH([gdm_config],
		AC_HELP_STRING([--with-gdm-config=file],
			[The location of the GDM configuration file]),
		[gdmconfigfile="$withval"])

if test "x$gdmconfigfile" = "x" -o "x$gdmconfigfile" = "xyes"; then
	AC_MSG_CHECKING([for gdm.conf])

	if test -f "/etc/gdm/gdm.conf"; then
		gdmconfigfile="/etc/gdm/gdm.conf"
	elif test -f "/etc/X11/gdm/gdm.conf"; then
		gdmconfigfile="/etc/X11/gdm/gdm.conf"
	elif test -f "/etc/opt/gnome/gdm/gdm.conf"; then
		gdmconfigfile="/etc/opt/gnome/gdm/gdm.conf"
	else
		gdmconfigfile=""
	fi

	AC_MSG_RESULT([$gdmconfigfile])
elif test "x$gdmconfigfile" = "xno"; then
	gdmconfigfile=""
else
	AC_MSG_RESULT([using "$gdmconfigfile" as the gdm.conf location])
fi

AC_DEFINE_UNQUOTED(GDMCONFIGFILE, "$gdmconfigfile", [The location of the GDM configuration file])

enable_user_switching=no
if test "x$gdmconfigfile" != "x" -a "x$gdmconfigfile" != "xno"; then
	enable_user_switching=yes
	AC_DEFINE(HAVE_USER_SWITCHING, 1, [Define if user switching is available])
fi

AM_CONDITIONAL(HAVE_USER_SWITCHING, test x$enable_user_switching = xyes)
AC_SUBST(HAVE_USER_SWITCHING)



#Checks for header files
#Checks for typefs, structures, and compiler characteristics.
#Checks for library functions


#Output files
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
	Makefile
	src/Makefile
	src/libssui.pc
	src/icons/Makefile
	src/gnome-session-logout.desktop
	src/gnome-session-shutdown.desktop
	src/fusa-code/Makefile
	src/gnome-session-code/Makefile
	po/Makefile.in
])
AC_OUTPUT

